﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using DGSFramework;

namespace Framework.UnderConstruction
{
    public partial class Default : System.Web.UI.Page
    {
        public string strUnderContructionTimePublish;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadInfomation();
        }

        public void LoadInfomation()
        {
            XDocument xDocInfo = XDocument.Load(Server.MapPath(ConfigPaths.Path_Infomation_Xml));

            XElement xEInfomationCompany = xDocInfo.Descendants("company").FirstOrDefault();
            //ltrWebsite.Text = "<a href='http://" + xEInfomationCompany.Element("website").Value.Trim() + "' title='" + xEInfomationCompany.Element("website").Value.Trim() + "'>" + xEInfomationCompany.Element("website").Value.Trim() + "</a>";
            aCompanyName.Title = aCompanyName.InnerText = ltrCompanyName.Text = ltrCompanyName2.Text = xEInfomationCompany.Element("companyname").Value.Trim();
            aCompanyName.HRef = "http://" + xEInfomationCompany.Element("website").Value.Trim();

            XElement xEInfomationConfigWebsite = xDocInfo.Descendants("ConfigWebsite").FirstOrDefault();
            XElement xEUnderContructionTimePublish = xEInfomationConfigWebsite.Descendants("UnderContruction").FirstOrDefault().Descendants("TimePublish").FirstOrDefault();
            strUnderContructionTimePublish = !string.IsNullOrEmpty(xEUnderContructionTimePublish.Value.Trim()) ?
                DateTime.ParseExact(xEUnderContructionTimePublish.Value.Trim(), "dd/MM/yyyy", null)
                        .ToString("yyyy/MM/dd", null) : 
                "";
            ltrGA.Text = HttpUtility.HtmlDecode(xEInfomationConfigWebsite.Element("GoogleAnalytics").Value.Trim());
            ltrMetaHeader.Text = HttpUtility.HtmlDecode(xEInfomationConfigWebsite.Element("MetaHeader").Value.Trim());
        }
    }
}